<?php

declare(strict_types=1);

namespace App\Entity;

use App\Models\OrderServiceInfo;

/**
 * 订单服务信息
 * Class OrderServiceInfoEntity
 */
class OrderServiceInfoEntity extends ABaseEntity
{
    public function __construct(OrderServiceInfo $model)
    {
        $this->model = $model;
    }

    /**
     * @return OrderServiceInfoEntity|null
     */
    public static function findByOrderId(int $orderId)
    {
        $model = OrderServiceInfo::where('order_id', $orderId)
            ->where('status', OrderServiceInfo::STATUS_VALID)
            ->orderBy('id', 'desc')
            ->first();
        if ($model === null) {
            return null;
        }

        return new self($model);
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->model->id;
    }

    public function setOrderId(int $orderId)
    {
        $this->model->order_id = $orderId;
    }

    /**
     * @return int
     */
    public function getOrderId()
    {
        return (int) $this->model->order_id;
    }

    public function getServiceStart(): string
    {
        return (string) $this->model->service_start;
    }

    public function setServiceStart(string $service_start): void
    {
        $this->model->service_start = $service_start;
    }

    public function getServiceFinish(): string
    {
        return (string) $this->model->service_finish;
    }

    public function setServiceFinish(string $service_finish): void
    {
        $this->model->service_finish = $service_finish;
    }

    public function getCleanerId(): int
    {
        return (int) $this->model->cleaner_id;
    }

    public function setCleanerId(int $cleaner_id): void
    {
        $this->model->cleaner_id = $cleaner_id;
    }

    public function getCleanerName(): string
    {
        return (string) $this->model->cleaner_name;
    }

    public function setCleanerName(string $cleaner_name): void
    {
        $this->model->cleaner_name = $cleaner_name;
    }

    public function getStatus(): int
    {
        return $this->model->status;
    }

    public function setStatus(int $status): void
    {
        $this->model->status = $status;
    }
}
